#include "myresource.h"
#include <QImage>
#ifdef Q_OS_SYMBIAN
#include <volumeKey/volumeKey.h>
#include <player/PlayerUtility.h>
#endif// Q_OS_SYMBIAN
#include <QCoreApplication>
#include <QObject>

QImage   *MyResource::m_buttonImage = NULL;
QImage   *MyResource::m_buttonpImage = NULL;
QImage   *MyResource::m_setbtnImage = NULL;
QImage   *MyResource::m_infobtnImage = NULL;
QImage   *MyResource::m_infobtnpImage = NULL;
QImage   *MyResource::m_setbtnpImage = NULL;
QImage   *MyResource::m_promatbgImage = NULL;
QImage   *MyResource::m_helpbtnImage = NULL;
QImage   *MyResource::m_quitbtnImage = NULL;
QImage   *MyResource::m_helpbtnpImage = NULL;
QImage   *MyResource::m_quitbtnpImage = NULL;
QImage   *MyResource::m_staticbtnImage = NULL;
QImage   *MyResource::m_staticbtnpImage = NULL;
QImage   *MyResource::m_lockImage = NULL;
QImage   *MyResource::m_gameaboutbtnImage = NULL;
QImage   *MyResource::m_gamePromptMenoImage = NULL;
QImage   *MyResource::m_gamePromptNumeberImage = NULL;
QImage   *MyResource::m_gameErrorImage = NULL;
QImage   *MyResource::m_gamePromptNoMenoImage = NULL;
VolumeKey   *MyResource::m_iVolumeKey = NULL;
PlayerUtility   *MyResource::m_clickcellplay = NULL;
PlayerUtility   *MyResource::m_clickplay = NULL;
PlayerUtility   *MyResource::m_rightplay = NULL;
PlayerUtility   *MyResource::m_winplay = NULL;

MyResource::MyResource()
{
}

void MyResource::initImage()
{
    m_buttonImage = new QImage(":/image/main/buttonbg.png");
    m_buttonpImage = new QImage(":/image/main/buttonbgp.png");
    m_setbtnImage = new QImage(":/image/main/set.png");
    m_infobtnImage = new QImage(":/image/main/info.png");
    m_infobtnpImage = new QImage(":/image/main/infop.png");
    m_setbtnpImage = new QImage(":/image/main/setp.png");
    m_promatbgImage = new QImage(":/image/main/promptbg.png");
    m_helpbtnImage = new QImage(":/image/main/help.png");
    m_helpbtnpImage = new QImage(":/image/main/helpp.png");
    m_quitbtnImage = new QImage(":/image/main/quit.png");
    m_quitbtnpImage = new QImage(":/image/main/quitp.png");
    m_staticbtnImage = new QImage(":/image/main/statis.png");
    m_staticbtnpImage = new QImage(":/image/main/statisp.png");
    m_lockImage = new QImage(":/image/main/lock.png");
    m_gameaboutbtnImage = new QImage(":/image/game/about.png");
    m_gamePromptMenoImage = new QImage(":/image/game/prompt_meno.png");
    m_gamePromptNumeberImage = new QImage(":/image/game/prompt_number.png");
    m_gameErrorImage = new QImage(":/image/game/error.png");
    m_gamePromptNoMenoImage = new QImage(":/image/game/prompt_nomeno.png");

#ifdef Q_OS_SYMBIAN
    QString path = QCoreApplication::applicationDirPath();
    path.replace("/","\\");
    m_clickcellplay = new PlayerUtility( path + "\\Resources\\cellclick.wav", NULL, 5 );
    m_iVolumeKey = new VolumeKey(NULL);

    connect(m_iVolumeKey,SIGNAL(VolumeKeyPressed(int)),m_clickcellplay,SLOT(volumeKeyPressed(int)));

    m_clickplay = new PlayerUtility( path + "\\Resources\\press.wav",NULL,5);
    m_rightplay = new PlayerUtility( path + "\\Resources\\right.wav",NULL,5);
    m_winplay = new PlayerUtility( path + "\\Resources\\win.mp3",NULL,5);
    connect(m_iVolumeKey,SIGNAL(VolumeKeyPressed(int)),m_clickplay,SLOT(volumeKeyPressed(int)));
    connect(m_iVolumeKey,SIGNAL(VolumeKeyPressed(int)),m_rightplay,SLOT(volumeKeyPressed(int)));
    connect(m_iVolumeKey,SIGNAL(VolumeKeyPressed(int)),m_winplay,SLOT(volumeKeyPressed(int)));
#endif
}

void MyResource::play(int n)
{
#ifdef Q_OS_SYMBIAN

    switch(n)
    {
    case 0:
    {
        m_clickcellplay->play();
    }
        break;
    case 1:
    {
        m_clickplay->play();
    }
        break;
    case 2:
    {
        m_rightplay->play();
    }
        break;
    case 3:
    {
        m_winplay->play();
    }
        break;
    default:
        break;
    }

#endif
}



